package com.zzs.path.entity;

import lombok.Getter;
import lombok.Setter;

import java.util.Objects;

@Getter
@Setter
public class AStarNode {

    int index;
    Node node;
    int g;
    int h;
    AStarNode parent;

    public int f(){
        return g+h;
    }

    public AStarNode(int index, Node node, int g, int h, AStarNode parent) {
        this.index = index;
        this.node = node;
        this.g = g;
        this.h = h;
        this.parent = parent;
    }

    @Override // 因为要存放到 HashSet 中，需要重写 equals 和 hashCode 方法
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AStarNode aStarNode = (AStarNode) o;
        return Objects.equals(node, aStarNode.node);
    }

    @Override
    public int hashCode() {
        return Objects.hash(node);
    }
}
